@echo off
chcp 65001 > nul
echo ====== 农机监控系统 - API功能测试 ======
echo 测试服务器: http://localhost:8080/api
echo.

set BASE_URL=http://localhost:8080/api

echo 1. 设备管理API测试
echo --------------------------------

echo 测试: 获取所有设备
curl -s "%BASE_URL%/devices" -H "Content-Type: application/json"
echo.
echo.

echo 测试: 获取工作中的设备
curl -s "%BASE_URL%/devices/status/WORKING" -H "Content-Type: application/json"
echo.
echo.

echo 测试: 获取设备ID=1
curl -s "%BASE_URL%/devices/1" -H "Content-Type: application/json"
echo.
echo.

echo 测试: 获取不存在的设备(应该返回404)
curl -s "%BASE_URL%/devices/999" -H "Content-Type: application/json"
echo.
echo.

echo 2. 路径管理API测试  
echo --------------------------------

echo 测试: 获取所有路径
curl -s "%BASE_URL%/paths" -H "Content-Type: application/json"
echo.
echo.

echo 测试: 获取设备1的路径
curl -s "%BASE_URL%/paths/device/1" -H "Content-Type: application/json"
echo.
echo.

echo 3. 地块管理API测试
echo --------------------------------

echo 测试: 获取所有地块
curl -s "%BASE_URL%/parcels" -H "Content-Type: application/json"
echo.
echo.

echo 测试: 获取地块ID=1
curl -s "%BASE_URL%/parcels/1" -H "Content-Type: application/json"
echo.
echo.

echo 测试: 获取地块1的面积
curl -s "%BASE_URL%/parcels/1/area" -H "Content-Type: application/json"
echo.
echo.

echo 4. 创建操作测试
echo --------------------------------

echo 测试: 创建新设备
curl -s -X POST "%BASE_URL%/devices" ^
     -H "Content-Type: application/json" ^
     -d "{\"deviceName\":\"测试拖拉机01\",\"deviceType\":\"TRACTOR\",\"status\":\"OFFLINE\",\"currentPosition\":{\"x\":116.4074,\"y\":39.9042}}"
echo.
echo.

echo ====== 测试完成 ======
echo.
echo 注意事项：
echo 1. 确保MySQL数据库运行并包含测试数据
echo 2. 确保Spring Boot应用在端口8080运行  
echo 3. 如果测试失败，检查应用日志
pause